<!doctype html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>移除双列管</title>
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css"/>
    <script src="/static/js/common/common.js" type="text/javascript"></script>
    <link href="/webjars/miniui/css/demo.css" rel="stylesheet" type="text/css"/>
    <link href="/static/css/default.css" rel="stylesheet" type="text/css"/>
    <style>
        .discell {
            text-align: right;
            width: 130px;
        }
        .input {
            width: 150px;
        }
    </style>
</head>
<body>
<div class="mini-fit">
    <div style="height:100%;width: 100%;overflow-x: auto;overflow-y: auto;">
        <form id="form1" method="post" style="margin-left: 40px;">
            <input name="pid" id="priNum" class="mini-hidden" style="width: 100%" readonly/>
            <br>
            <table style="height: 100%;width: 100%;">
                <tr>
                    <td class="discell"><font color="#dc143c">*</font>解除人:</td>
                    <td class="input" colspan="2">
                        <input property="editor" class="mini-textbox" id="relieveName" name="relieveName" style="width: 300px" required="true" value="${username!''}"/>
                    </td>
                </tr>
                <tr>
                    <td class="discell"><font color="#dc143c">*</font>解除人手机号码:</td>
                    <td class="input" colspan="2">
                        <input property="editor" class="mini-textbox" onvaluechanged="checkPhone(2)" id="relievePhone" name="relievePhone" style="width: 300px"  value="${phone!''}"/>
                    </td>
                </tr>
                <tr>
                    <td class="discell"><font color="#dc143c">*</font>解除人固话:</td>
                    <td class="input" colspan="2">
                        <input property="editor" class="mini-textbox" onvaluechanged="checkPhone(1)" id="relieveTel1" name="relieveTel1" style="width: 300px"  value="${tel!''}"/>
                    </td>
                </tr>
                <tr>
                    <td class="input" colspan="2">
                        <input  class="mini-hidden" id="relieveTel" name="relieveTel"/>
                    </td>
                </tr>
                <tr>
                    <td class="discell">解除时间:</td>
                    <td class="input" colspan="2">
                        <input property="editor" class="mini-textbox" id="dateJc" name="dateJc" style="width: 300px" readonly/>
                    </td>
                </tr>
                <tr>
                    <td class="discell"><font color="#dc143c">*</font>解除原因:</td>
                    <td class="input" colspan="2">
                        <input class="mini-textarea" id="reasonJc" name="reasonJc" style="width: 300px;height:100px" required="true"
                               emptyText="请输入内容(0-200):" maxlength="200"/>
                    </td>
                </tr>
            </table>
        </form>
        <div style="padding:2px;margin: 0 auto;text-align: center">
            <a class="mini-button" iconCls="fa-save" plain="true" onclick="saveData()">确定</a>
            <a class="mini-button" iconCls="fa-save" plain="true" onclick="onCancel()">取消</a>
        </div>
    </div>
</div>
<script type="text/javascript">

    mini.parse();
    var form = new mini.Form("form1");
    var priNum = mini.get("priNum");
    var dateJc = mini.get("dateJc");
    var relieveTel1 = mini.get("relieveTel1");
    var relievePhone = mini.get("relievePhone");

    function saveData(){
        form.validate();
        if (form.isValid() == false) {
            return;
        }
        var phone = relievePhone.getValue();
        var tel = relieveTel1.getValue();
        var newPhone = checkTelAndPhone(tel,phone);
        var flag = newPhone['flag'];
        var kflag = newPhone['kflag'];
        if ('-1' === kflag) {
            mini.alert("请至少输入一个联系方式");
            return;
        }
        if (flag) {
        } else {
            mini.alert("手机号码或固话有误，请重填");
            return;
        }
        mini.get("relieveTel").setValue(newPhone['newTelAndPhone']);
        var data = form.getData();
        var json = mini.encode(data);
        //alert("json:" + json);
        $.ajax({
            url : "/azbj/azbjgl/slg/removeslg/save",
            data : {data: json},
            type : "post",
            success: function (success){
                if(success.code == 1){
                    mini.alert("解除成功","信息提示",function () {
                        onCancel();
                    });
                } else if (success.code == 5599) {
                    mini.alert(success.message);
                } else{
                    mini.alert("解除失败");
                }
            }

        });
    }

    window.onload = function () {
        priNum.setValue(${priNum!''});
        var myDate = new Date;
        var year = myDate.getFullYear(); //获取当前年
        var mon = myDate.getMonth() + 1; //获取当前月
        var date = myDate.getDate(); //获取当前日
        dateJc.setValue(year + "年" + mon + "月" + date + "日");
    }

    function checkPhone(e) {
        var phone = relievePhone.getValue();
        var telPhone = relieveTel.getValue();
        if (e == '1') {
            if(!validateTel(telPhone)) {
                mini.alert("固定电话有误，请重填");
            }
        }
        if (e == '2') {
            if(!validatePhone1(phone)) {
                mini.alert("手机号码有误，请重填");
            }
        }
    }
</script>
</body>
</html>